define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'resume/basicinfo/index' + location.search,
                    detail_url: 'resume/basicinfo/detail' + location.search,
                    add_url: 'resume/basicinfo/add',
                    edit_url: 'resume/basicinfo/edit',
                    del_url: 'resume/basicinfo/del',
                    multi_url: 'resume/basicinfo/multi',
                    import_url: 'resume/basicinfo/import',
                    table: 'resume_basicinfo',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'BasicinfoID',
                sortName: 'BasicinfoID',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'BasicinfoID', title: __('Basicinfoid')},
                        {field: 'AdminID', title: __('Adminid')},
                        {field: 'Name', title: __('Name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'Gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"2":__('Gender 2')}, formatter: Table.api.formatter.normal},
                        {field: 'MobileNum', title: __('Mobilenum'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'Email', title: __('Email'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'DateOfBirth', title: __('Dateofbirth'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'WorkYear', title: __('Workyear'), operate:'BETWEEN'},
                        {field: 'CurrentLocation', title: __('Currentlocation'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'MaritalStatus', title: __('Maritalstatus'), searchList: {"1":__('Maritalstatus 1'),"2":__('Maritalstatus 2'),"3":__('Maritalstatus 3')}, formatter: Table.api.formatter.status},
                        {field: 'Height', title: __('Height'), operate:'BETWEEN'},
                        {field: 'Residency', title: __('Residency'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'EducationCategory', title: __('Educationcategory'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'JobSearchStatus', title: __('Jobsearchstatus'), searchList: {"1":__('Jobsearchstatus 1'),"2":__('Jobsearchstatus 2'),"3":__('Jobsearchstatus 3'),"4":__('Jobsearchstatus 4')}, formatter: Table.api.formatter.status},
                        {field: 'Remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'CreatedTime', title: __('Createdtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {field: 'UpdatedTime', title: __('Updatedtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
                        {
                            field: 'operate',
                            title: __('Operate'),
                            table: table,
                            buttons: [
                                {
                                    name: 'detail',
                                    title: __('Detail'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: $.fn.bootstrapTable.defaults.extend.detail_url,
                                }
                            ],
                            events: Table.api.events.operate,
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
